package com.login.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.common.util.BaseAction;
import com.login.action.fo.HotProductFO;
import com.login.service.IHotProductServ;

public class HotProductAction extends BaseAction {
	private static final long serialVersionUID = 1L;
	public static Logger log = Logger.getLogger(HotProductAction.class);
	private HotProductFO fo;
	private int id;
	private String title;
	private String type;
	private String content;
	private int author;
	private String  createTime;
	private String  isAutho;
	private  int orderNum;

	private IHotProductServ servHot;
	private int page;
	private int rows;
	private int total;
	public String searchFinaList() {
		Map<String, Object> paraMap = new HashMap<String, Object>();

		int start = (page - 1) * rows;
		int end = page * rows;
		paraMap.put("start", start);
		paraMap.put("end", end);
		String result = servHot.searchFinaList(paraMap);
		PrintWriter out =null;
			try {
				 out = response.getWriter();
				response.setCharacterEncoding("utf-8");
				out.write(result);

			} catch (IOException e) {
				log.error("search fina error", e);
			}
		//	return "success"; 不能这样返回  引起前台页面数据展现不出来		
			return null;
		}
	
	public String addSaveFina()
	{
		Map<String, Object> paraMap = new HashMap<String, Object>();
		paraMap.put("title", title);
		paraMap.put("orderNum", orderNum);
		paraMap.put("type", type);
		paraMap.put("content", content);
		paraMap.put("author", author);
		paraMap.put("createTime", createTime);
		paraMap.put("isAutho", isAutho);
		servHot.saveSysmenu(paraMap);
		return "success";
	}
	
	public static void main(String[] args) 
	{
		
		//System.out.print(dateToString("2011-01-02 01:00:00"));
	}
	  private  Date dateToString(String str) {

	        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	        Date date = null;
	        try {
	         date = format.parse(str);
	        } catch (ParseException e) {
	         e.printStackTrace();
	        }
	        return date;

	    }
	  
	public String deleteByIds() throws IOException {
		try {
			String ids = request.getParameter( "ids");
			boolean isFlag =servHot.deleteByIdString(ids);
			response.setContentType("text/html;charset=utf-8");
			if (isFlag)
				message = "删除成功";
			else
				message = "删除失败";
			StringBuffer sb = new StringBuffer("[");
			sb.append("{\"message\":\"" + message + "\"" + "}");
			sb.append("]");
			this.response.getWriter().print(sb.toString());
		} catch (Exception e) {
			log.error("delete menulist error", e);
		}
		return null;
	}
	public HotProductFO getFo() {
		return fo;
	}
	public void setFo(HotProductFO fo) {
		this.fo = fo;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public int getAuthor() {
		return author;
	}
	public void setAuthor(int author) {
		this.author = author;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getIsAutho() {
		return isAutho;
	}
	public void setIsAutho(String isAutho) {
		this.isAutho = isAutho;
	}
	public int getOrderNum() {
		return orderNum;
	}
	public void setOrderNum(int orderNum) {
		this.orderNum = orderNum;
	}
	public int getPage() {
		return page;
	}
	public void setPage(int page) {
		this.page = page;
	}
	public int getRows() {
		return rows;
	}
	public void setRows(int rows) {
		this.rows = rows;
	}
	public int getTotal() {
		return total;
	}
	public void setTotal(int total) {
		this.total = total;
	}

	public void setServHot(IHotProductServ servHot) {
		this.servHot = servHot;
	}

	
	

}
